export default {
  data () {
    return {
      security: []
    }
  },
  methods: {
    // 设置表头
    getTableColumns (arr) {
      const tableColumns = {
        selection: {
          type: 'selection',
          width: 60,
          align: 'center',
          fixed: 'left'
        },
        companyName: {
          title: '公司名称',
          width: 200,
          // ellipsis: true,
          align: 'center',
          key: 'companyName',
          render: (h, params) => {
            let row = params.row
            let name = row.companyName
            if (row.statusName === '待申报') {
              return h('div', {
                class: 'ellipsis'
              }, [
                h('span', {
                  class: 'iconfont icon-new'
                }, ''),
                h('span', name)
              ])
            } else {
              return h('div', name)
            }
          }
        },
        changeType: {
          title: '异动类型',
          width: 100,
          align: 'center',
          key: 'changeType',
          render: (h, params) => {
            let row = params.row
            let str = row.columns.ChangeType
            return h('span', str)
          }
        },
        identityCardNO: {
          title: '身份证号码',
          width: 190,
          align: 'center',
          key: 'identityCardNO'
        },
        name: {
          title: '姓名',
          width: 90,
          align: 'center',
          key: 'name'
        },
        sex: {
          title: '性别',
          width: 80,
          align: 'center',
          key: 'sex',
          render: (h, params) => {
            let row = params.row
            let str = row.columns.Sex
            return h('span', str)
          }
        },
        birthDay: {
          title: '出生日期',
          width: 150,
          align: 'center',
          key: 'birthDay',
          render: (h, params) => {
            let row = params.row
            let times = row.birthDay.slice(0, 10).replace(/-/g, '')
            return h('span', times)
          }
        },
        statusName: {
          title: '处理结果',
          width: 110,
          align: 'center',
          key: 'statusName'
        },
        declareReason: {
          title: '申报失败原因',
          width: 150,
          tooltip: true,
          align: 'center',
          key: 'declareReason'
        },
        securityNO: {
          title: '社保编号',
          width: 140,
          tooltip: true,
          align: 'center',
          key: 'securityNO'
        },
        planName: {
          title: '社保方案',
          width: 100,
          align: 'center',
          tooltip: true,
          key: 'planName'
        },
        commissionerUserName: {
          title: '社保专员',
          align: 'center',
          minWidth: 110,
          key: 'commissionerUserName'
        },
        serverName: {
          title: '所属客服',
          width: 100,
          align: 'center',
          key: 'serverName'
        },
        employeeTypeName: {
          title: '用工形式',
          width: 150,
          align: 'center',
          key: 'employeeTypeName'
        },
        changeTime: {
          title: '申报时间',
          width: 150,
          align: 'center',
          key: 'changeTime',
          render: (h, params) => {
            let row = params.row
            let times = row.changeTime.slice(0, 10).replace(/-/g, '')
            return h('span', times)
          }
        },
        declareSalary: {
          title: '申报工资',
          width: 150,
          align: 'center',
          key: 'declareSalary',
          render: (h, params) => {
            let row = params.row
            let str = row.declareSalary
            if (str && str != 0) {
              return h('span', str)
            } else {
              return h('span', '')
            }
          }
        },
        baseAmount: {
          title: '社保基数',
          width: 150,
          align: 'center',
          key: 'baseAmount'
        },
        pension_c: {
          title: '养老（单位）',
          width: '150px',
          align: 'center',
          key: 'pension_c',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'Pension'
            })
            if (str) {
              return h('span', str.company_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        pension_e: {
          title: '养老（个人）',
          width: '150px',
          align: 'center',
          key: 'pension_e',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'Pension'
            })
            if (str) {
              return h('span', str.employee_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        medicalCare_c: {
          title: '医疗（单位）',
          width: '150px',
          align: 'center',
          key: 'medicalCare_c',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'MedicalCare'
            })
            if (str) {
              return h('span', str.company_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        medicalCare_e: {
          title: '医疗（个人）',
          width: '150px',
          align: 'center',
          key: 'medicalCare_e',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'MedicalCare'
            })
            if (str) {
              return h('span', str.employee_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        unemployment_c: {
          title: '失业（单位）',
          width: '150px',
          align: 'center',
          key: 'unemployment_c',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'Unemployment'
            })
            if (str) {
              return h('span', str.company_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        unemployment_e: {
          title: '失业（个人）',
          width: '150px',
          align: 'center',
          key: 'unemployment_e',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'Unemployment'
            })
            if (str) {
              return h('span', str.employee_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        injuryOnTheJob_c: {
          title: '工伤（单位）',
          width: '150px',
          align: 'center',
          key: 'injuryOnTheJob_c',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'InjuryOnTheJob'
            })
            if (str) {
              return h('span', str.company_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        injuryOnTheJob_e: {
          title: '工伤（个人）',
          width: '150px',
          align: 'center',
          key: 'injuryOnTheJob_e',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'InjuryOnTheJob'
            })
            if (str) {
              return h('span', str.employee_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        birth_c: {
          title: '生育（单位）',
          width: '150px',
          align: 'center',
          key: 'birth_c',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'Birth'
            })
            if (str) {
              return h('span', str.company_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        birth_e: {
          title: '生育（个人）',
          width: '150px',
          align: 'center',
          key: 'birth_e',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'Birth'
            })
            if (str) {
              return h('span', str.employee_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        disabledPersonsSecurityFund: {
          title: '残疾人保障金',
          width: '150px',
          align: 'center',
          key: 'disabledPersonsSecurityFund',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'DisabledPersonsSecurityFund'
            })
            if (str) {
              return h('span', str.company_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        seriousIllness_c: {
          title: '大病医疗（单位）',
          width: '150px',
          align: 'center',
          key: 'seriousIllness_c',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'SeriousIllness'
            })
            if (str) {
              return h('span', str.company_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        seriousIllness_e: {
          title: '大病医疗（个人）',
          width: '150px',
          align: 'center',
          key: 'seriousIllness_e',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'SeriousIllness'
            })
            if (str) {
              return h('span', str.employee_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        outpatientDepartment_c: {
          title: '门诊医疗（单位）',
          width: '150px',
          align: 'center',
          key: 'outpatientDepartment_c',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'OutpatientDepartment'
            })
            if (str) {
              return h('span', str.company_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        outpatientDepartment_e: {
          title: '门诊医疗（个人）',
          width: '150px',
          align: 'center',
          key: 'outpatientDepartment_e',
          render: (h, params) => {
            let row = params.row.details
            let str = row.find(item => {
              return item.securityTypeCode === 'OutpatientDepartment'
            })
            if (str) {
              return h('span', str.employee_BaseAmount)
            } else {
              return h('span', 0)
            }
          }
        },
        leaveReason: {
          title: '离职原因',
          width: '150px',
          align: 'center',
          key: 'leaveReason'
        },
        description: {
          title: '备注',
          width: '150px',
          align: 'center',
          key: 'description'
        },
        phone: {
          title: '手机号码',
          width: 140,
          align: 'center',
          key: 'phone'
        },
        idCardEndTime: {
          title: '证件到期时间',
          width: 120,
          align: 'center',
          key: 'idCardEndTime',
          render: (h, params) => {
            let row = params.row
            let times = ''
            if (row.idCardEndTime) {
              times = row.idCardEndTime.slice(0, 10).replace(/-/g, '')
            }
            return h('span', times)
          }
        },
        duty: {
          title: '职业',
          width: 100,
          align: 'center',
          key: 'duty'
        },
        residentAddress: {
          title: '现居住地',
          width: 200,
          tooltip: true,
          align: 'center',
          key: 'residentAddress'
        },
        auditTime: {
          title: '创建时间',
          width: 190,
          align: 'center',
          key: 'auditTime',
          render: (h, params) => {
            let row = params.row
            let times = ''
            if (row.auditTime) {
              times = row.auditTime.slice(0, 19).replace(/T/g, ' ')
            }
            return h('span', times)
          }
        },
        action: {
          title: '操作',
          minWidth: 180,
          align: 'center',
          slot: 'action',
          fixed: 'right'
        },
      }
      let data = []

      arr.forEach(col => data.push(tableColumns[col]))

      return data
    }
  }
}
